<?php

use yii\db\Schema;
use yii\db\Migration;

class m150209_062304_add_opt_price_table extends Migration
{
	public function up()
	{
		$sql = <<<FINE

CREATE TABLE {{%opt_price}} (
  id int(11) NOT NULL AUTO_INCREMENT,
  adspace_id int(11) NOT NULL COMMENT 'SSP平台的广告位ID',
  solution_id int(11) NOT NULL,
  opt_cpc decimal(12, 2) NOT NULL,
  opt_cpm decimal(12, 2) NOT NULL,
  base_price decimal(12, 2) NOT NULL,
  price decimal(12,2) NOT NULL COMMENT '价格，表初始生成时为 opt_cpm 价格，后续不由 UI维护',
  status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '默认为0, 1 表示 cpm 有变动',
  last_update timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

FINE;
		$this->execute($sql);
    }

    public function down()
    {
        $this->dropTable('{{%opt_price}}');
    }
}
